<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>按钮</button>
    <script>
        class Father {
            constructor(name, age) {
                this.name = name;
                this.age = age;
                // 获取元素
                this.button = document.querySelector("button");
                this.button.onclick = this.fn();
            }
            fn() {
                console.log(this.name + this.age);
            }
        };
        var fathers = new Father(11, 22);
        // var button = document.querySelector("button");
        // button.onclick = function() {
        //     console.log(ss.fn());
        // }
    </script>
</body>

</html>